<?php

namespace app\admin\controller;

use app\admin\model\Admin;
use think\Controller;
use think\Db;
use think\Request;

class Member extends Common
{
    /**
     * 显示资源列表
     *
     * @return \think\Response
     */
    public function user()
    {
        return view('user');
    }
    public function getUserData()
    {
        $tableId = (new Admin())->searchall();
        return ['code'=>0,'msg'=>'查询用户成功','data'=>$tableId,'count'=>"20"];
    }
    public function Eduser(){
        $data=\request()->param();
        $id=$data['id'];
        $res=Db::name('admin')->where('Id',$id)->find();
        $this->assign('res',$res);
        return view('user-edit');
    }


    /**
     * 新增用户
     */
    public function addUser(){
        return view('user-add');
    }
    public function save(Request $request)
    {
        //新增
        return (new Admin())->addUser($request->param());
    }

    /**
     *
     * 启用
     * */
    public function normalUser(){
        $data=\request()->param();
        $res=(new Admin())->Upuser($data);
        return ['code'=>0,'msg'=>'success'];
    }

    /**
     *
     * 停用
     * */
    public function dormalUser(){
        $data=\request()->param();
        $res=(new Admin())->Douser($data);
        return ['code'=>0,'msg'=>'success'];
    }

    public function deleteUser(){
        $data=\request()->param();
        $res=(new Admin())->delUser($data);
        return ['code'=>0,'msg'=>'success'];
    }


}
